﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>

<%
    StockCollection sc = (StockCollection)ViewData["StocksModel"];
    if (sc.Stocks.Count > 0)
    { 
%>
    <div id="stocksPreview">
        <h1>Stocks</h1>
        <%
            foreach (KeyValuePair<String, Stock> pair in sc.Stocks)
            {
                Stock stock = pair.Value;
                %>
                    <div>
                        <a href="<%=Url.Action("Stock", "Widgets") %>?symbol=<%=stock.Symbol %>"><b><%=stock.Symbol %></b></a>&nbsp;-
                        <span>
                            <%=stock.CurrentPrice.ToString("c") %>&nbsp;-&nbsp;
                        </span>
                        <span class="<%=(stock.DifferentialProfit < 0 ? "stockNeg" : "stockPos") %>">
                            <%=stock.DifferentialProfit.ToString("c") %>
                        </span>
                    </div>
                <%
            }
        %>
    </div>
<% 
    } 
%>